from django.contrib import admin
from .models import (
Movie, RatingDistribution, MovieType, 
YearDistribution, CountryStats, CrawlLog
)
@admin.register(RatingDistribution)
class RatingDistributionAdmin(admin.ModelAdmin):
    list_display = ('rating', 'count')
    ordering = ('rating',)
@admin.register(Movie)
class MovieAdmin(admin.ModelAdmin):
    list_display = ('title', 'rating', 'year', 'country', 'genre', 'created_at')
    list_filter = ('year', 'rating', 'country', 'genre')
    search_fields = ('title', 'country', 'genre')
    date_hierarchy = 'created_at'
    ordering = ('-rating',)
@admin.register(MovieType)
class MovieTypeAdmin(admin.ModelAdmin):
    list_display = ('type_name', 'count')
    ordering = ('-count',)
@admin.register(YearDistribution)
class YearDistributionAdmin(admin.ModelAdmin):
    list_display = ('year', 'count')
    ordering = ('year',)
@admin.register(CountryStats)
class CountryStatsAdmin(admin.ModelAdmin):
    list_display = ('country', 'count')
    ordering = ('-count',)
@admin.register(CrawlLog)
class CrawlLogAdmin(admin.ModelAdmin):
    list_display = ('start_time', 'end_time', 'status', 'movie_count')
    list_filter = ('status',)
    date_hierarchy = 'start_time'
    ordering = ('-start_time',)
    readonly_fields = ('start_time', 'end_time', 'status', 'movie_count', 'error_message')